package net.zhangyun.futures;

import net.zhangyun.utils.MyConsole;

import java.util.stream.IntStream;
import java.util.stream.Stream;

public class StreamMain {
    public static void main(String[] args) {
        blockStream();
    }

    private static void blockStream() {
        Stream<Integer> numbers = IntStream.range(1,4).boxed();

        int sum = numbers
                .map(number -> number + 1)
                .filter(number -> number >= 2)
                .flatMap(number -> {
                    //MyConsole.printSingle(number);
                    //MyConsole.printSingle(IntStream.range(1,number).boxed().toArray());
                    return IntStream.range(1,number).boxed();
                })
                .reduce(0, Integer::sum);

        MyConsole.printSingle(sum);
    }
}
